Table of Contents
- Importing Data
- Analysis of experiment metrics
- Heatmap
- Heatmap_reversal
- Strategies
- OLD Graphs
- UPDATED Graphs
- Probe Trial Graphs
- Layout Test
- Arena Quadrant Problem
- t-Tests
- Logistic regression
Importing Data
Here a multicore CPU cluster is opened to reduce experiment reading times. This cluster is closed after the execution of the code.
cluster = parallel::makeCluster(rep("localhost", parallel::detectCores()), type = "SOCK")
experiment = Rtrack::read_experiment("Experiment_description2.xlsx", format = "Excel", cluster = cluster)
parallel::stopCluster(cluster)Analysis of experiment metrics
These metrics can be compared and extracted from the pure track files.
experiment$summary.variables [1] "path.length" "mean.velocity"
[3] "sd.velocity" "total.time"
[5] "latency.to.goal" "goal.crossings"
[7] "old.goal.crossings" "coverage"
[9] "mean.d.centroid" "mean.d.goal"
[11] "mean.d.old.goal" "mean.d.origin"
[13] "sd.d.centroid" "sd.d.goal"
[15] "sd.d.old.goal" "sd.d.origin"
[17] "centroid.goal.displacement" "centroid.old.goal.displacement"
[19] "mean.initial.heading.error" "initial.trajectory.error"
[21] "initial.reversal.error" "turning"
[23] "turning.absolute" "efficiency"
[25] "roaming.entropy" "time.in.zone.pool"
[27] "time.in.zone.wall" "time.in.zone.far.wall"
[29] "time.in.zone.annulus" "time.in.zone.goal"
[31] "time.in.zone.old.goal" "time.in.zone.n.quadrant"
[33] "time.in.zone.e.quadrant" "time.in.zone.s.quadrant"
[35] "time.in.zone.w.quadrant"
par(mfrow = c(2, 2))
Rtrack::plot_variable("path.length", experiment = experiment, factor = "Strain", exclude.probe = TRUE,lwd = 2)
Rtrack::plot_variable("path.length", experiment = experiment, factor = "Age_group", exclude.probe = TRUE,lwd = 2)
Rtrack::plot_variable("path.length", experiment = experiment, factor = "Housing", exclude.probe = TRUE,lwd = 2)
Rtrack::plot_variable("path.length", experiment = experiment, factor = "All", exclude.probe = TRUE,lwd = 2) Note that the probe trials have been omitted from these plots.
Heatmap
wt.metrics = experiment$metrics[experiment$factors$Strain == "WT" &
(experiment$factors$`_Day` == 1 | experiment$factors$`_Day` == 2 | experiment$factors$`_Day` == 3 | experiment$factors$`_Day` == 4|
experiment$factors$`_Day` == 5| experiment$factors$`_Day` == 6)]
dTg.metrics = experiment$metrics[experiment$factors$Strain == "dTg" &
(experiment$factors$`_Day` == 1 | experiment$factors$`_Day` == 2 | experiment$factors$`_Day` == 3 | experiment$factors$`_Day` == 4| experiment$factors$`_Day` == 5| experiment$factors$`_Day` == 6)]
APP.metrics = experiment$metrics[experiment$factors$Strain == "APPswe" &
(experiment$factors$`_Day` == 1 | experiment$factors$`_Day` == 2 | experiment$factors$`_Day` == 3 | experiment$factors$`_Day` == 4| experiment$factors$`_Day` == 5| experiment$factors$`_Day` == 6)]
PS1.metrics = experiment$metrics[experiment$factors$Strain == "PS1dE9" &
(experiment$factors$`_Day` == 1 | experiment$factors$`_Day` == 2 | experiment$factors$`_Day` == 3 | experiment$factors$`_Day` == 4| experiment$factors$`_Day` == 5| experiment$factors$`_Day` == 6)]
par(mfrow = c(2, 2))
Rtrack::plot_density(wt.metrics, title = "wt Heatmap",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTg.metrics, title = "dTg Heatmap",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APP.metrics, title = "APPswe Heatmap",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1.metrics, title = "PS1dE9 Heatmap",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))Heatmap_reversal
wtr.metrics = experiment$metrics[experiment$factors$Strain == "WT" &
(experiment$factors$`_Day` == 7 | experiment$factors$`_Day` == 8 | experiment$factors$`_Day` == 9 | experiment$factors$`_Day` == 10)]
dTgr.metrics = experiment$metrics[experiment$factors$Strain == "dTg" &
(experiment$factors$`_Day` == 7 | experiment$factors$`_Day` == 8 | experiment$factors$`_Day` == 9 | experiment$factors$`_Day` == 10)]
APPr.metrics = experiment$metrics[experiment$factors$Strain == "APPswe" &
(experiment$factors$`_Day` ==7 | experiment$factors$`_Day` == 8 | experiment$factors$`_Day` == 9 | experiment$factors$`_Day` == 10)]
PS1r.metrics = experiment$metrics[experiment$factors$Strain == "PS1dE9" &
(experiment$factors$`_Day` == 7 | experiment$factors$`_Day` == 8 | experiment$factors$`_Day` == 9 | experiment$factors$`_Day` == 10)]
par(mfrow = c(2, 2))
Rtrack::plot_density(wtr.metrics, title = "WT_reversal Heatmap",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgr.metrics, title = "dTg_reversal Heatmap",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPr.metrics, title = "APPswe_reversal Heatmap",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1r.metrics, title = "PS1dE9_reversal Heatmap",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))Strategies
Calling strategies
strategies = Rtrack::call_strategy(experiment$metrics)Thresholding strategies
limits called strategies to those, where confidence is greater than 40%
dim(Rtrack::threshold_strategies(strategies, 0.4)$calls)[1] 4203 12
Plotting strategies of all age groups combined
par(mfrow = c(2, 2))
Rtrack::plot_strategies(strategies, experiment = experiment, factor = "Strain",
exclude.probe = TRUE)Plotting thresholded strategies of all age groups combined
par(mfrow = c(2, 2))
Rtrack::plot_strategies(Rtrack::threshold_strategies(strategies, 0.4), experiment = experiment,
factor = "Strain", exclude.probe = TRUE)Saving the results
Here we export the results of the analyzed Track Files into a data.frame, to analyse them further.
results = Rtrack::export_results(experiment)
datatable(results, rownames = FALSE, filter="top", options = list(pageLength = 5, scrollX=T) )OLD Graphs
Plotting with ggplot2
library(ggplot2)
library(readxl)
Results=read_excel("Results3.xlsx", col_types=c("text","text","text","text","text","text","logical","numeric","text","text","text","numeric","text","numeric","text","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric"))
ggplot(Results, aes(x=`_Day`,y=path.length,color=factor(Strain)))+geom_jitter()Results# A tibble: 5,960 x 60
Track_ID `_TargetID` `_Day` `_Trial` `_Arena` Condition Probe Trial Strain
<chr> <chr> <chr> <chr> <chr> <chr> <lgl> <dbl> <chr>
1 Track_4 60-911 1 1 Arena_SW.t~ WT_STD FALSE 4 WT
2 Track_8 60-293 1 1 Arena_SW.t~ WT_STD FALSE 8 WT
3 Track_9 60-296 1 1 Arena_SW.t~ WT_STD FALSE 9 WT
4 Track_10 60-333 1 1 Arena_SW.t~ dTg_STD FALSE 10 dTg
5 Track_14 60-911 1 2 Arena_SW.t~ WT_STD FALSE 14 WT
6 Track_18 60-293 1 2 Arena_SW.t~ WT_STD FALSE 18 WT
7 Track_19 60-296 1 2 Arena_SW.t~ WT_STD FALSE 19 WT
8 Track_20 60-333 1 2 Arena_SW.t~ dTg_STD FALSE 20 dTg
9 Track_24 60-911 1 3 Arena_SW.t~ WT_STD FALSE 24 WT
10 Track_28 60-293 1 3 Arena_SW.t~ WT_STD FALSE 28 WT
# ... with 5,950 more rows, and 51 more variables: Housing <chr>,
# Age_group <chr>, Age_months <dbl>, All <chr>, strategy <dbl>, name <chr>,
# confidence <dbl>, 1 <dbl>, 2 <dbl>, 3 <dbl>, 4 <dbl>, 5 <dbl>, 6 <dbl>,
# 7 <dbl>, 8 <dbl>, 9 <dbl>, path.length <dbl>, mean.velocity <dbl>,
# sd.velocity <dbl>, total.time <dbl>, latency.to.goal <dbl>,
# goal.crossings <dbl>, old.goal.crossings <dbl>, coverage <dbl>,
# mean.d.centroid <dbl>, mean.d.goal <dbl>, mean.d.old.goal <dbl>,
# mean.d.origin <dbl>, sd.d.centroid <dbl>, sd.d.goal <dbl>,
# sd.d.old.goal <dbl>, sd.d.origin <dbl>, centroid.goal.displacement <dbl>,
# centroid.old.goal.displacement <dbl>, mean.initial.heading.error <dbl>,
# initial.trajectory.error <dbl>, initial.reversal.error <dbl>,
# turning <dbl>, turning.absolute <dbl>, efficiency <dbl>,
# roaming.entropy <dbl>, time.in.zone.pool <dbl>, time.in.zone.wall <dbl>,
# time.in.zone.far.wall <dbl>, time.in.zone.annulus <dbl>,
# time.in.zone.goal <dbl>, time.in.zone.old.goal <dbl>,
# time.in.zone.n.quadrant <dbl>, time.in.zone.e.quadrant <dbl>,
# time.in.zone.s.quadrant <dbl>, time.in.zone.w.quadrant <dbl>
CAREFUL!!! The graphs below still include the probe trials (day 7 trial 1). To remove them add: Probe==‘FALSE’ to filter
Path Length Graphs
WT_STD=filter(Results, Strain=='WT'&Housing=='STD')
dTg_STD=filter(Results, Strain=='dTg'&Housing=='STD')
APP_STD=filter(Results, Strain=='APPswe'&Housing=='STD')
PS_STD=filter(Results, Strain=='PS1dE9'&Housing=='STD')
WT_ENR=filter(Results, Strain=='WT'&Housing=='ENR')
dTg_ENR=filter(Results, Strain=='dTg'&Housing=='ENR')
APP_ENR=filter(Results, Strain=='APPswe'&Housing=='ENR')
PS_ENR=filter(Results, Strain=='PS1dE9'&Housing=='ENR')
par(mfrow = c(2, 4))
WT_STD %>%
mutate(WT_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Path length",
title="Mean Path length WT STD")+scale_fill_jco()dTg_STD %>%
mutate(dTg_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Path length",
title="Mean Path length dTg STD")+scale_fill_jco()APP_STD %>%
mutate(APP_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Path length",
title="Mean Path length APPswe1 STD")+scale_fill_jco()PS_STD %>%
mutate(PS_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Path length",
title="Mean Path length PS1dE9 STD")+scale_fill_jco()WT_ENR %>%
mutate(WT_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Path length",
title="Mean Path length WT ENR")+scale_fill_jco()dTg_ENR %>%
mutate(dTg_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Path length",
title="Mean Path length dTg ENR")+scale_fill_jco()APP_ENR %>%
mutate(APP_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Path length",
title="Mean Path length APPswe1 ENR")+scale_fill_jco()PS_ENR %>%
mutate(PS_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Path length",
title="Mean Path length PS1dE9 ENR")+scale_fill_jco()+
facet_wrap(~Age_group)Latency Graphs
WT_STD %>%
mutate(WT_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Latency in s",
title="Mean Latency in s WT STD")+scale_fill_jco()dTg_STD %>%
mutate(dTg_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Latency in s",
title="Mean Latency in s dTg STD")+scale_fill_jco()APP_STD %>%
mutate(APP_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Latency in s",
title="Mean Latency in s APPswe1 STD")+scale_fill_jco()PS_STD %>%
mutate(PS_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Latency in s",
title="Mean Latency in s PS1dE9 STD")+scale_fill_jco()WT_ENR %>%
mutate(WT_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Latency in s",
title="Mean Latency in s WT ENR")+scale_fill_jco()dTg_ENR %>%
mutate(dTg_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Latency in s",
title="Mean Latency in s dTg ENR")+scale_fill_jco()APP_ENR %>%
mutate(APP_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Latency in s",
title="Mean Latency in s APPswe1 ENR")+scale_fill_jco()PS_ENR %>%
mutate(PS_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
labs(x="Day",
y="Average Latency in s",
title="Mean Latency in s PS1dE9 ENR")+scale_fill_jco()+
facet_wrap(~Age_group)UPDATED Graphs
Heatmap_probe
par(mfrow = c(2, 2))
Rtrack::plot_density(wtp.metrics, title = "WT Probe Heatmap 3-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgp.metrics, title = "dTg Probe Heatmap 3-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPp.metrics, title = "APPswe Probe Heatmap 3-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1p.metrics, title = "PS1dE9 Probe Heatmap 3-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))par(mfrow = c(2, 4))
Rtrack::plot_density(wtpstd.metrics, title = "WT Probe Heatmap STD 3-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgpstd.metrics, title = "dTg Probe Heatmap STD 3-25mo", col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPpstd.metrics, title = "APPswe Probe Heatmap STD 3-25mo", col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1pstd.metrics, title = "PS1dE9 Probe Heatmap STD 3-25mo", col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(wtpenr.metrics, title = "WT Probe Heatmap ENR 3-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgpenr.metrics, title = "dTg Probe Heatmap ENR 3-25mo", col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPpenr.metrics, title = "APPswe Probe Heatmap ENR 3-25mo", col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1penr.metrics, title = "PS1dE9 Probe Heatmap ENR 3-25mo", col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100)) WT -> dTg -> APPswe -> PS1dE9
par(mfrow = c(1, 3))
###########WT_Probe##########
Rtrack::plot_density(wtpstd3.metrics, title = "WT Probe Heatmap STD 3mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(wtpstd14.metrics, title = "WT Probe Heatmap STD 13-14mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(wtpstd25.metrics, title = "WT Probe Heatmap STD 17-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))Rtrack::plot_density(wtpenr3.metrics, title = "WT Probe Heatmap ENR 3mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(wtpenr14.metrics, title = "WT Probe Heatmap ENR 13-14mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(wtpenr25.metrics, title = "WT Probe Heatmap ENR 17-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))###########dTg_Probe##########
Rtrack::plot_density(dTgpstd3.metrics, title = "dTg Probe Heatmap STD 3mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgpstd14.metrics, title = "dTg Probe Heatmap STD 13-14mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgpstd25.metrics, title = "dTg Probe Heatmap STD 17-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))Rtrack::plot_density(dTgpenr3.metrics, title = "dTg Probe Heatmap ENR 3mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgpenr14.metrics, title = "dTg Probe Heatmap ENR 13-14mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgpenr25.metrics, title = "dTg Probe Heatmap ENR 17-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))###########APP_Probe##########
Rtrack::plot_density(APPpstd3.metrics, title = "APPswe Probe Heatmap STD 3mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
#Rtrack::plot_density(APPpstd14.metrics, title = "APPswe Probe Heatmap STD 13-14mo",
# col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPpstd25.metrics, title = "APPswe Probe Heatmap STD 17-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPpenr3.metrics, title = "APPswe Probe Heatmap ENR 3mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))#Rtrack::plot_density(APPpenr14.metrics, title = "APPswe Probe Heatmap ENR 13-14mo",
# col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPpenr25.metrics, title = "APPswe Probe Heatmap ENR 17-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
###########PS1_Probe##########
Rtrack::plot_density(PS1pstd3.metrics, title = "PS1dE9 Probe Heatmap STD 3mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
#Rtrack::plot_density(PS1pstd14.metrics, title = "PS1dE9 Probe Heatmap STD 13-14mo",
# col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1pstd25.metrics, title = "PS1dE9 Probe Heatmap STD 17-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))Rtrack::plot_density(PS1penr3.metrics, title = "PS1dE9 Probe Heatmap ENR 3mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
#Rtrack::plot_density(PS1penr14.metrics, title = "PS1dE9 Probe Heatmap ENR 13-14mo",
# col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1penr25.metrics, title = "PS1dE9 Probe Heatmap ENR 17-25mo",
col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))Path Length Graphs
mo3=filter(Results, Age_group=='3')
mo14=filter(Results, Age_group=='13-14')
mo25=filter(Results, Age_group=='17-25')
mo3 %>%
mutate(mo3, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Condition))+geom_boxplot()+
labs(x="Day",
y="Average Path length",
title="Mean Path length 3mo mice")+scale_fill_manual(values = c("dTg_ENR" = "#ad5fc9", "dTg_STD" = "#bc91cc","WT_ENR" = "#6eca64", "WT_STD" = "#98cc93","APPswe_ENR" = "#d6564b", "APPswe_STD" = "#db867f","PS1dE9_ENR" = "#918730", "PS1dE9_STD" = "#c5b740"))mo14 %>%
mutate(mo14, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Condition))+geom_boxplot()+
labs(x="Day",
y="Average Path length",
title="Mean Path length 13-14mo mice")+scale_fill_manual(values = c("dTg_ENR" = "#ad5fc9", "dTg_STD" = "#bc91cc","WT_ENR" = "#6eca64", "WT_STD" = "#98cc93","APPswe_ENR" = "#d6564b", "APPswe_STD" = "#db867f","PS1dE9_ENR" = "#918730", "PS1dE9_STD" = "#c5b740"))mo25 %>%
mutate(mo25, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Condition))+geom_boxplot()+
labs(x="Day",
y="Average Path length",
title="Mean Path length 17-25mo mice")+scale_fill_manual(values = c("dTg_ENR" = "#6c7ed7", "dTg_STD" = "#909ef3","WT_ENR" = "#9f48a3", "WT_STD" = "#ce73cf","APPswe_ENR" = "#c85632", "APPswe_STD" = "#e9724b","PS1dE9_ENR" = "#9f9201", "PS1dE9_STD" = "#cab95b"))Boxplot explanation:
Middle line in box -> Median
Box -> shows middle 50% of data(Distance between 1. and 3. Quartil)
Whisker(vertikal lines) -> show upper/lower 25% of data w/o outliers
Points -> outlier
Velocity (Mean) Graphs
mo3=filter(Results, Age_group=='3')
mo14=filter(Results, Age_group=='13-14')
mo25=filter(Results, Age_group=='17-25')
mo3 %>%
mutate(mo3, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=mean.velocity, fill=Condition))+geom_boxplot()+
labs(x="Day",
y="Average Velocity",
title="Mean Velocity 3mo mice")+scale_fill_manual(values = c("dTg_ENR" = "#ad5fc9", "dTg_STD" = "#bc91cc","WT_ENR" = "#6eca64", "WT_STD" = "#98cc93","APPswe_ENR" = "#d6564b", "APPswe_STD" = "#db867f","PS1dE9_ENR" = "#918730", "PS1dE9_STD" = "#c5b740"))mo14 %>%
mutate(mo14, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=mean.velocity, fill=Condition))+geom_boxplot()+
labs(x="Day",
y="Average Velocity",
title="Mean Velocity 13-14mo mice")+scale_fill_manual(values = c("dTg_ENR" = "#ad5fc9", "dTg_STD" = "#bc91cc","WT_ENR" = "#6eca64", "WT_STD" = "#98cc93","APPswe_ENR" = "#d6564b", "APPswe_STD" = "#db867f","PS1dE9_ENR" = "#918730", "PS1dE9_STD" = "#c5b740"))mo25 %>%
mutate(mo25, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=mean.velocity, fill=Condition))+geom_boxplot()+
labs(x="Day",
y="Average Velocity",
title="Mean Velocity 17-25mo mice")+scale_fill_manual(values = c("dTg_ENR" = "#6c7ed7", "dTg_STD" = "#909ef3","WT_ENR" = "#9f48a3", "WT_STD" = "#ce73cf","APPswe_ENR" = "#c85632", "APPswe_STD" = "#e9724b","PS1dE9_ENR" = "#9f9201", "PS1dE9_STD" = "#cab95b"))Strategy (Thresholded) Graphs
par(mfrow = c(2, 2))
Rtrack::plot_strategies(Rtrack::threshold_strategies(strategies, 0.4), experiment = experiment,
factor = "All", exclude.probe = TRUE)Probe Trial Graphs
Probe Trial Number of Goals Crossings
mo3.probe=filter(Results, Age_group=='3'&`_Day`=='7'&`_Trial`=='1')
mo14.probe=filter(Results, Age_group=='13-14'&`_Day`=='7'&`_Trial`=='1')
mo25.probe=filter(Results, Age_group=='17-25'&`_Day`=='7'&`_Trial`=='1')
mo3.probe %>%
ggplot(aes(x=`Strain`,y=goal.crossings, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Number of Goal Crossings",
title="Probe Trial Number of Goal Crossings 3mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))mo14.probe %>%
ggplot(aes(x=`Strain`,y=goal.crossings, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Number of Goal Crossings",
title="Probe Trial Number of Goal Crossings 13-14mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))mo25.probe %>%
ggplot(aes(x=`Strain`,y=goal.crossings, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Number of Goal Crossings",
title="Probe Trial Number of Goal Crossings 17-25mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))Probe Trial Number of former Goals Crossings
mo3.probe=filter(Results, Age_group=='3'&`_Day`=='7'&`_Trial`=='1')
mo14.probe=filter(Results, Age_group=='13-14'&`_Day`=='7'&`_Trial`=='1')
mo25.probe=filter(Results, Age_group=='17-25'&`_Day`=='7'&`_Trial`=='1')
mo3.probe %>%
ggplot(aes(x=`Strain`,y=old.goal.crossings, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Number of old Goal Crossings",
title="Probe Trial Number of former Goal Crossings 3mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))mo14.probe %>%
ggplot(aes(x=`Strain`,y=old.goal.crossings, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Number of old Goal Crossings",
title="Probe Trial Number of former Goal Crossings 13-14mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))mo25.probe %>%
ggplot(aes(x=`Strain`,y=old.goal.crossings, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Number of Old Goal Crossings",
title="Probe Trial Number of former Goal Crossings 17-25mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))Probe Trial Time in old goal zone
mo3.probe=filter(Results, Age_group=='3'&`_Day`=='7'&`_Trial`=='1')
mo14.probe=filter(Results, Age_group=='13-14'&`_Day`=='7'&`_Trial`=='1')
mo25.probe=filter(Results, Age_group=='17-25'&`_Day`=='7'&`_Trial`=='1')
mo3.probe %>%
ggplot(aes(x=`Strain`,y=time.in.zone.old.goal, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Time in s",
title="Probe Trial Time spent in old goal 3mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))mo14.probe %>%
ggplot(aes(x=`Strain`,y=old.goal.crossings, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Time in s",
title="Probe Trial Time spent in old goal 13-14mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))mo25.probe %>%
ggplot(aes(x=`Strain`,y=old.goal.crossings, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Time in s",
title="Probe Trial Time spent in old goal 17-25mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))Probe Trial Mean Initial heading error
mo3.probe=filter(Results, Age_group=='3'&`_Day`=='7'&`_Trial`=='1')
mo14.probe=filter(Results, Age_group=='13-14'&`_Day`=='7'&`_Trial`=='1')
mo25.probe=filter(Results, Age_group=='17-25'&`_Day`=='7'&`_Trial`=='1')
mo3.probe %>%
ggplot(aes(x=`Strain`,y=`mean.initial.heading.error`, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Initial heading error in %??",
title="Probe Trial Mean Initial heading error 3mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))mo14.probe %>%
ggplot(aes(x=`Strain`,y=`mean.initial.heading.error`, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Initial heading error in %??",
title="Probe Trial Mean Initial heading error 13-14mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))mo25.probe %>%
ggplot(aes(x=`Strain`,y=`mean.initial.heading.error`, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Initial heading error in ???",
title="Probe Trial Mean Initial heading error 17-25mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))Probe Trial Mean Distance old goal
3 Months
mo3.probe %>%
ggplot(aes(x=`Strain`,y=`mean.d.old.goal`, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Distance",
title="Probe Trial Mean Distance old goal 3mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))13-14 Months
mo14.probe %>%
ggplot(aes(x=`Strain`,y=`mean.d.old.goal`, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Distance",
title="Probe Trial Mean Distance old goal 13-14mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))17-25 Months
mo25.probe %>%
ggplot(aes(x=`Strain`,y=`mean.d.old.goal`, fill=Housing))+geom_boxplot()+
labs(x="Condition",
y="Distance",
title="Probe Trial Mean Distance old goal 17-25mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))Arena Quadrant Problem
knitr::include_graphics("Watermaze_Setup.png") In Ethovision those Quadrants are marked (NE, SE, SW, NW).
In contrast to that, the quadrants that can be analyzed with RTrack are called as below:
“time.in.zone.n.quadrant”
“time.in.zone.e.quadrant”
“time.in.zone.s.quadrant”
“time.in.zone.w.quadrant”
knitr::include_graphics("Watermaze_Quadrant.png")t-Tests
t-Tests (time in old goal zone of probe trials) between Age Groups
3 / 13-14
t.test(mo3.probe$time.in.zone.old.goal,mo14.probe$time.in.zone.old.goal)
Welch Two Sample t-test
data: mo3.probe$time.in.zone.old.goal and mo14.probe$time.in.zone.old.goal
t = 0.41802, df = 55.572, p-value = 0.6775
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.4742248 0.7242732
sample estimates:
mean of x mean of y
1.248872 1.123847
3 / 17-25
t.test(mo3.probe$time.in.zone.old.goal,mo25.probe$time.in.zone.old.goal)
Welch Two Sample t-test
data: mo3.probe$time.in.zone.old.goal and mo25.probe$time.in.zone.old.goal
t = -0.76178, df = 53.252, p-value = 0.4496
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.8365670 0.3759891
sample estimates:
mean of x mean of y
1.248872 1.479161
13-14 / 17-25
t.test(mo14.probe$time.in.zone.old.goal,mo25.probe$time.in.zone.old.goal)
Welch Two Sample t-test
data: mo14.probe$time.in.zone.old.goal and mo25.probe$time.in.zone.old.goal
t = -0.96822, df = 62.942, p-value = 0.3366
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-1.0886658 0.3780395
sample estimates:
mean of x mean of y
1.123847 1.479161
no significance between the overall groups
t-Tests (time in old goal zone of probe trials) between Strains & Housings of Age Group 17-25
17-25 WT STD/ENR
WTS.mo25.probe=filter(mo25.probe, Strain=='WT'&`Housing`=='STD')
WTE.mo25.probe=filter(mo25.probe, Strain=='WT'&`Housing`=='ENR')
t.test(WTS.mo25.probe$time.in.zone.old.goal,WTE.mo25.probe$time.in.zone.old.goal)
Welch Two Sample t-test
data: WTS.mo25.probe$time.in.zone.old.goal and WTE.mo25.probe$time.in.zone.old.goal
t = 1.2667, df = 15.225, p-value = 0.2243
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.5876549 2.3148994
sample estimates:
mean of x mean of y
2.196897 1.333275
13-14 WT STD/ENR
WTS.mo14.probe=filter(mo14.probe, Strain=='WT'&`Housing`=='STD')
WTE.mo14.probe=filter(mo14.probe, Strain=='WT'&`Housing`=='ENR')
t.test(WTS.mo14.probe$time.in.zone.old.goal,WTE.mo14.probe$time.in.zone.old.goal)
Welch Two Sample t-test
data: WTS.mo14.probe$time.in.zone.old.goal and WTE.mo14.probe$time.in.zone.old.goal
t = -0.4615, df = 11.792, p-value = 0.6528
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-2.172106 1.414007
sample estimates:
mean of x mean of y
1.278296 1.657345
3 WT STD/ENR
WTS.mo3.probe=filter(mo3.probe, Strain=='WT'&`Housing`=='STD')
WTE.mo3.probe=filter(mo3.probe, Strain=='WT'&`Housing`=='ENR')
t.test(WTS.mo3.probe$time.in.zone.old.goal,WTE.mo3.probe$time.in.zone.old.goal)
Welch Two Sample t-test
data: WTS.mo3.probe$time.in.zone.old.goal and WTE.mo3.probe$time.in.zone.old.goal
t = 0.86513, df = 16.892, p-value = 0.3991
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.8315724 1.9866145
sample estimates:
mean of x mean of y
1.724105 1.146584
no significance found
t-Tests (Path length of all trials) between Strains
17-25 WT/dTg
mo25.WT=filter(mo25, Strain=="WT")
mo25.dTg=filter(mo25, Strain=="dTg")
t.test(mo25.WT$path.length,mo25.dTg$path.length)
Welch Two Sample t-test
data: mo25.WT$path.length and mo25.dTg$path.length
t = -7.4557, df = 286.47, p-value = 1.067e-12
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-333.6846 -194.2992
sample estimates:
mean of x mean of y
667.5763 931.5682
17-25 WT/PS1dE9
mo25.WT=filter(mo25, Strain=="WT")
mo25.PS=filter(mo25, Strain=="PS1dE9")
t.test(mo25.WT$path.length,mo25.PS$path.length)
Welch Two Sample t-test
data: mo25.WT$path.length and mo25.PS$path.length
t = -2.4789, df = 228.85, p-value = 0.0139
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-183.21674 -20.94064
sample estimates:
mean of x mean of y
667.5763 769.6550
17-25 WT/APPswe
mo25.WT=filter(mo25, Strain=="WT")
mo25.AP=filter(mo25, Strain=="APPswe")
t.test(mo25.WT$path.length,mo25.AP$path.length)
Welch Two Sample t-test
data: mo25.WT$path.length and mo25.AP$path.length
t = -3.6486, df = 268.81, p-value = 0.0003167
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-217.38161 -65.00338
sample estimates:
mean of x mean of y
667.5763 808.7688
17-25 PS1dE9/APPswe
mo25.PS=filter(mo25, Strain=="PS1dE9")
mo25.AP=filter(mo25, Strain=="APPswe")
t.test(mo25.PS$path.length,mo25.AP$path.length)
Welch Two Sample t-test
data: mo25.PS$path.length and mo25.AP$path.length
t = -0.7493, df = 357.63, p-value = 0.4542
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-141.77175 63.54414
sample estimates:
mean of x mean of y
769.6550 808.7688
17-25 dTg/PS1dE9
mo25.dTg=filter(mo25, Strain=="dTg")
mo25.AP=filter(mo25, Strain=="PS1dE9")
t.test(mo25.dTg$path.length,mo25.PS$path.length)
Welch Two Sample t-test
data: mo25.dTg$path.length and mo25.PS$path.length
t = 3.2506, df = 343.79, p-value = 0.001266
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
63.94184 259.88464
sample estimates:
mean of x mean of y
931.5682 769.6550
17-25 dTg/APPswe
mo25.dTg=filter(mo25, Strain=="dTg")
mo25.AP=filter(mo25, Strain=="APPswe")
t.test(mo25.dTg$path.length,mo25.AP$path.length)
Welch Two Sample t-test
data: mo25.dTg$path.length and mo25.AP$path.length
t = 2.5701, df = 380.87, p-value = 0.01055
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
28.85462 216.74425
sample estimates:
mean of x mean of y
931.5682 808.7688
t-Tests (Latency to goal of all trials) between Strains
17-25 WT/dTg
mo25.WT=filter(mo25, Strain=="WT")
mo25.dTg=filter(mo25, Strain=="dTg")
t.test(mo25.WT$latency.to.goal,mo25.dTg$latency.to.goal)
Welch Two Sample t-test
data: mo25.WT$latency.to.goal and mo25.dTg$latency.to.goal
t = -1.2135, df = 75.087, p-value = 0.2287
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-7.80585 1.89582
sample estimates:
mean of x mean of y
21.66102 24.61604
17-25 WT/PS1dE9
mo25.WT=filter(mo25, Strain=="WT")
mo25.PS=filter(mo25, Strain=="PS1dE9")
t.test(mo25.WT$latency.to.goal,mo25.PS$latency.to.goal)
Welch Two Sample t-test
data: mo25.WT$latency.to.goal and mo25.PS$latency.to.goal
t = 0.20491, df = 121.95, p-value = 0.838
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-3.458770 4.257498
sample estimates:
mean of x mean of y
21.66102 21.26166
17-25 WT/APPswe
mo25.WT=filter(mo25, Strain=="WT")
mo25.AP=filter(mo25, Strain=="APPswe")
t.test(mo25.WT$latency.to.goal,mo25.AP$latency.to.goal)
Welch Two Sample t-test
data: mo25.WT$latency.to.goal and mo25.AP$latency.to.goal
t = -0.54994, df = 133.82, p-value = 0.5833
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-4.522667 2.554791
sample estimates:
mean of x mean of y
21.66102 22.64496
17-25 PS1dE9/APPswe
mo25.PS=filter(mo25, Strain=="PS1dE9")
mo25.AP=filter(mo25, Strain=="APPswe")
t.test(mo25.PS$latency.to.goal,mo25.AP$latency.to.goal)
Welch Two Sample t-test
data: mo25.PS$latency.to.goal and mo25.AP$latency.to.goal
t = -0.56912, df = 180.51, p-value = 0.57
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-6.179354 3.412750
sample estimates:
mean of x mean of y
21.26166 22.64496
17-25 dTg/PS1dE9
mo25.dTg=filter(mo25, Strain=="dTg")
mo25.AP=filter(mo25, Strain=="PS1dE9")
t.test(mo25.dTg$latency.to.goal,mo25.PS$latency.to.goal)
Welch Two Sample t-test
data: mo25.dTg$latency.to.goal and mo25.PS$latency.to.goal
t = 1.1414, df = 127.49, p-value = 0.2558
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-2.460675 9.169433
sample estimates:
mean of x mean of y
24.61604 21.26166
17-25 dTg/APPswe
mo25.dTg=filter(mo25, Strain=="dTg")
mo25.AP=filter(mo25, Strain=="APPswe")
t.test(mo25.dTg$latency.to.goal,mo25.AP$latency.to.goal)
Welch Two Sample t-test
data: mo25.dTg$latency.to.goal and mo25.AP$latency.to.goal
t = 0.69518, df = 118.95, p-value = 0.4883
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-3.643181 7.585335
sample estimates:
mean of x mean of y
24.61604 22.64496
Logistic regression
Results table can be seen here
Strategy Legend
- 1 - thigmotaxis
- 2 - circling
- 3 - random path
- 4 - scanning
- 5 - chaining
- 6 - directed search
- 7 - corrected search
- 8 - direct path
- 9 - perseverance
Strategies 1-5 are less hippocampus-dependent, ‘unspatial’ and therefore get strategy.class = 0. In contrast to that, strategies 6-9 are more hippocampus-dependent, ‘spatial’ and get strategy.class = 1 assigned.
All probabilities in the following codes relate to choosing strategy.class = 1.
setwd("C:/Google/Uni/Bachelorarbeit/R/Analysis")
logistic.data=read_excel("logistic.reg.xlsx")Age Group 17-25 Housing
logistic.data.1725=filter(logistic.data, Age_group1725=='1')fitting different logistic regression models with increasing complexity
simple model including housing only
logreg.1725.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = logistic.data.1725)simple model including Strain only
logreg.1725.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = logistic.data.1725)additive model including all factors
logreg.1725.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = logistic.data.1725)interaction model including all factors
logreg.1725.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = logistic.data.1725)Model comparisons using the anova function
anova(logreg.1725.add.1b, logreg.1725.add.1a, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 1308 1775.6
2 1310 1811.7 -2 -36.096 1.452e-08 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model including Strain better than model including housing
anova(logreg.1725.add.2, logreg.1725.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 1307 1774.6
2 1308 1775.6 -1 -1.0162 0.3134
adding factor housing does not improve the model
anova(logreg.1725.int, logreg.1725.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 1304 1771.3
2 1308 1775.6 -4 -4.3588 0.3596
interaction model not better than additive model simple model including Strain only is the minimal adequate model
summary of minimal adequate model
summary(logreg.1725.add.1b)
Call:
glm(formula = strategy.class ~ Strain, family = binomial, data = logistic.data.1725)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.325 -1.222 1.037 1.037 1.475
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.10318 0.14378 0.718 0.472979
StraindTg -0.78083 0.20945 -3.728 0.000193 ***
StrainPS1dE9 -0.03339 0.20966 -0.159 0.873472
StrainWT 0.23739 0.16168 1.468 0.142040
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 1813.9 on 1311 degrees of freedom
Residual deviance: 1775.6 on 1308 degrees of freedom
AIC: 1783.6
Number of Fisher Scoring iterations: 4
exp(coef(logreg.1725.add.1b)) (Intercept) StraindTg StrainPS1dE9 StrainWT
1.1086957 0.4580270 0.9671628 1.2679321
impact of predictor “Strain”
pred.data <- data.frame(Strain=c("WT", "dTg", "PS1dE9", "APPswe"))
pred.data$prob <- predict(logreg.1725.add.1b, newdata = pred.data, type = "response")
pred.data Strain prob
1 WT 0.5843293
2 dTg 0.3367876
3 PS1dE9 0.5174419
4 APPswe 0.5257732
impact of predictor “housing”
pred.data2 <- data.frame(Housing=c("STD","ENR"))
pred.data2$prob <- predict(logreg.1725.add.1a, newdata = pred.data2, type = "response")
pred.data2 Housing prob
1 STD 0.5504451
2 ENR 0.5094044
Age group 13-14 Strain x Housing effects
logistic.data.1314=filter(logistic.data, Age_group1314=='1')fitting different logistic regression models with increasing complexity simple model including housing only
logreg.1314.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = logistic.data.1314)simple model including Strain only
logreg.1314.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = logistic.data.1314)additive model including all factors
logreg.1314.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = logistic.data.1314)interaction model including all factors
logreg.1314.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = logistic.data.1314)model comparisons using the anova function
anova(logreg.1314.add.1b, logreg.1314.add.1a, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 1306 1724.2
2 1306 1804.4 0 -80.16
no Df, same model fit?
anova(logreg.1314.add.2, logreg.1314.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 1305 1718.1
2 1306 1724.2 -1 -6.1765 0.01295 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
additive model shows significantly better fit (Pr=0.01295)
anova(logreg.1314.int, logreg.1314.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 1304 1712.2
2 1306 1724.2 -2 -11.999 0.00248 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
interaction model better than simple Strain model (Pr=0.00248) interaction model including Strain*Housing is the best fitting model
summary of minimal adequate model
summary(logreg.1314.int)
Call:
glm(formula = strategy.class ~ Housing * Strain, family = binomial,
data = logistic.data.1314)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.4842 -0.9285 -0.9253 1.1143 1.4525
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.626772 0.118643 -5.283 1.27e-07 ***
HousingSTD 0.008426 0.167152 0.050 0.9598
StrainWT 1.324112 0.163290 8.109 5.11e-16 ***
HousingSTD:StrainWT -0.555484 0.230430 -2.411 0.0159 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 1811.7 on 1307 degrees of freedom
Residual deviance: 1712.3 on 1304 degrees of freedom
AIC: 1720.3
Number of Fisher Scoring iterations: 4
exp(coef(logreg.1314.int)) (Intercept) HousingSTD StrainWT HousingSTD:StrainWT
0.5343137 1.0084617 3.7588467 0.5737945
impact of predictor "Strain*Housing"
pred.data <- data.frame(Strain=c("WT", "WT","dTg","dTg"),Housing=c("STD","ENR","STD","ENR"))
pred.data$prob <- predict(logreg.1314.int, newdata = pred.data, type = "response")
pred.data Strain Housing prob
1 WT STD 0.5375000
2 WT ENR 0.6675978
3 dTg STD 0.3501577
4 dTg ENR 0.3482428
Age group 3 Strain x Housing
logistic.data.3=filter(logistic.data, Age_group3=='1')fitting different logistic regression models with increasing complexity simple model including housing only
logreg.3.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = logistic.data.3)simple model including Strain only
logreg.3.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = logistic.data.3)additive model including all factors
logreg.3.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = logistic.data.3)interaction model including all factors
logreg.3.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = logistic.data.3)comparisons between model using the anova function
anova(logreg.3.add.1b, logreg.3.add.1a, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 3336 4458.5
2 3338 4516.0 -2 -57.513 3.245e-13 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model with Strain only is really good (Pr=3.245e-13)
anova(logreg.3.add.2, logreg.3.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 3335 4440.3
2 3336 4458.5 -1 -18.243 1.945e-05 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
adding factor housing also has good fit (Pr=1.945e-5)
anova(logreg.3.int, logreg.3.add.1b, test="Chisq")Analysis of Deviance Table
Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 3332 4428.8
2 3336 4458.5 -4 -29.694 5.648e-06 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
interaction model better than additive model (Pr=5.648e-6) interaction model is the best
summary of Strain only model
summary(logreg.3.add.1b)
Call:
glm(formula = strategy.class ~ Strain, family = binomial, data = logistic.data.3)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.4508 -1.3122 0.9267 1.0483 1.2183
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.31144 0.06899 4.514 6.35e-06 ***
StraindTg -0.40719 0.09715 -4.192 2.77e-05 ***
StrainPS1dE9 0.31166 0.09914 3.143 0.00167 **
StrainWT 0.30702 0.10290 2.984 0.00285 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 4529.0 on 3339 degrees of freedom
Residual deviance: 4458.5 on 3336 degrees of freedom
AIC: 4466.5
Number of Fisher Scoring iterations: 4
exp(coef(logreg.3.add.1b)) (Intercept) StraindTg StrainPS1dE9 StrainWT
1.3653846 0.6655165 1.3656859 1.3593683
summary of interaction model
summary(logreg.3.int)
Call:
glm(formula = strategy.class ~ Housing * Strain, family = binomial,
data = logistic.data.3)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.5713 -1.2014 0.8293 1.0221 1.2715
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.571375 0.099833 5.723 1.04e-08 ***
HousingSTD -0.515022 0.139153 -3.701 0.000215 ***
StraindTg -0.567129 0.135864 -4.174 2.99e-05 ***
StrainPS1dE9 0.319191 0.145466 2.194 0.028217 *
StrainWT -0.008040 0.153664 -0.052 0.958274
HousingSTD:StraindTg 0.292295 0.195814 1.493 0.135512
HousingSTD:StrainPS1dE9 0.001266 0.200208 0.006 0.994953
HousingSTD:StrainWT 0.610701 0.207830 2.938 0.003298 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 4529.0 on 3339 degrees of freedom
Residual deviance: 4428.8 on 3332 degrees of freedom
AIC: 4444.8
Number of Fisher Scoring iterations: 4
exp(coef(logreg.3.int)) (Intercept) HousingSTD StraindTg
1.7707006 0.5974872 0.5671514
StrainPS1dE9 StrainWT HousingSTD:StraindTg
1.3760135 0.9919925 1.3394975
HousingSTD:StrainPS1dE9 HousingSTD:StrainWT
1.0012672 1.8417220
impact of predictor “Strain”
pred.data3 <- data.frame(Strain=c("WT", "dTg", "PS1dE9", "APPswe"))
pred.data3$prob <- predict(logreg.3.add.1b, newdata = pred.data3, type = "response")
pred.data3 Strain prob
1 WT 0.6498674
2 dTg 0.4760793
3 PS1dE9 0.6509217
4 APPswe 0.5772358
impact of predictors “Strain x Housing”
pred.data3x <- data.frame(Strain=c("WT","WT", "dTg","dTg", "PS1dE9","PS1dE9", "APPswe","APPswe"),Housing=c("STD","ENR","STD","ENR","STD","ENR","STD","ENR"))
pred.data3x$prob <- predict(logreg.3.int, newdata = pred.data3x, type = "response")
pred.data3x Strain Housing prob
1 WT STD 0.6590389
2 WT ENR 0.6372240
3 dTg STD 0.4455959
4 dTg ENR 0.5010616
5 PS1dE9 STD 0.5931034
6 PS1dE9 ENR 0.7090069
7 APPswe STD 0.5140845
8 APPswe ENR 0.6390805
The full overview of the logistic regression results table is here.